<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    <ul>
      <li v-for="city in cities">
        {{city.name}} - {{city.num}}
      </li>
    </ul>
    {{total}}
  </div>
  <script>

    new Vue({
      el: "#app",
      data: {
        cities: [{ name: "太原", num: 800 }, { name: "北京", num: 3000 }]
      },
      computed: {
        total() {
          return this.cities.reduce((sum, item) => {
            return sum += item.num;
          }, 0)
        }
      },
      created() {
        fetch('http://127.0.0.1:8088/api/cities').then((res) => res.json())
          .then((res) => {
            console.log(res)
            this.cities = res;
          })
      }
    })

  </script>

</body>

</html>